import { _decorator, Component, math, Node, Vec2 } from 'cc';
import { PlayerState } from './PlayerState';
import { StateDefine } from '../../Config';
import { PlayerGroundState } from './PlayerGroundState';
const { ccclass, property } = _decorator;

@ccclass('PlayerIdleState')
export class PlayerIdleState extends PlayerGroundState {
    // stateTime = 0.05
    onEnter(): void {  
        super.onEnter();
        this.player.ZeroVelocity();
        // this.stateTime = 0.05;
        
    }
    update(deltaTime: number) {
        if(this.rb.linearVelocity!=Vec2.ZERO)this.player.ZeroVelocity();
        
        super.update(deltaTime);

        if(this.player.input.x != 0 && !this.player.isBusy/* ((this.stateTime-=deltaTime)<0) */){
            this.player.stateMgr.transit(StateDefine.Run);
        }
    }
    canTransit(to: StateDefine): boolean {
        if (to == StateDefine.Idle) {
            return false;
        }
        return true;
    }
    onExit(): void {
        super.onExit();
    }
    onDestory(): void {}
    
}


